// PrintWriter output;
BufferedWriter writer;

void setup() {
  // Create a new file in the sketch directory
  // output = createWriter("positions.txt"); 
  writer = new BufferedWriter(new FileWriter("position.txt", true));

}

void draw() {
  point(mouseX, mouseY);
  //output.println(mouseX + "t" + mouseY); // Write the coordinate to the file
  writer.write(mouseX + "t" + mouseY);
}

void keyPressed() {
  //output.flush(); // Writes the remaining data to the file
  //output.close(); // Finishes the file
  writer.close();
  exit(); // Stops the program
}

/*
BufferedWriter writer;

writer = new BufferedWriter(new FileWriter("filename", true));
writer.write("yourString\r\n");
writer.close();
*/
